﻿using FluentValidation.Results;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estoque.Core.Excecoes
{
    public class ValidacaoException: ApplicationException
    {
       public IList<ValidationFailure> Errors { get; private set; }

        public ValidacaoException(ValidationResult ValidationResult)
        {
            this.Errors = ValidationResult.Errors;
        }

        public override string Message
        {
            get
            {
                return string.Join("\n", Errors.Select(x => x.ErrorMessage));
            }
        }

    }
}
